package cn.liu.jetpack_demo.pages.user.components

import androidx.compose.foundation.background
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.width
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
import cn.liu.jetpack_demo.models.Person

@Composable
fun ListItem(person: Person) {
    Row(
        modifier = Modifier
            .background(color = Color.LightGray)
            .fillMaxWidth()
            .padding(24.dp),
        verticalAlignment = Alignment.CenterVertically
    ) {
        Text(
            text = "${person.username}",
            color = Color.Black,
            fontSize = 26.sp,
            fontWeight = FontWeight.Bold,
        )
        Spacer(modifier = Modifier.width(15.dp))
        Text(
            text = "${person.address}",
            color = Color.Gray,
            fontSize = 16.sp,
            fontWeight = FontWeight.Bold,
        )
        Spacer(modifier = Modifier.width(10.dp))
        Text(
            text = "${person.age}",
            color = Color.Gray,
            fontSize = 16.sp,
            fontWeight = FontWeight.Bold,
        )
    }
}

@Preview(name = "ListItem")
@Composable
private fun PreviewListItem() {
  ListItem(    Person(
      id = 1,
      username = "liuc",
      age = 22,
      address = "harbin",
      phone = "123456789",
      avatar = "https://avatars.githubusercontent.com/u/49747074?v=4"
  ))
}